﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace WPNextTools.NControls
{
    public abstract class VirtualizationStrategyDefinition : DependencyObject,INotifyPropertyChanged
    {
        #region Fields
        private Orientation _orientation;
        private double _columnMargin;
        private int _columnCount;
        private double _leftRightMargin;
        #endregion

        #region Properties
        public Orientation Orientation
        {
            get { return _orientation; }
            set
            {
                if (value != _orientation)
                {
                    _orientation = value;
                    this.OnPropertyChanged("Orientation");
                }
            }
        }

        public double ColumnMargin
        {
            get { return _columnMargin; }
            set
            {
                if (value != _columnMargin)
                {
                    _columnMargin = value;
                    this.OnPropertyChanged("ColumnMargin");
                }
            }
        }

        public int ColumnCount
        {
            get { return _columnCount; }
            set
            {
                if (value != _columnCount)
                {
                    _columnCount = value;
                    this.OnPropertyChanged("ColumnCount");
                }
            }
        }

        public double LeftRightMargin
        {
            get { return _leftRightMargin; }
            set
            {
                if (value != _leftRightMargin)
                {
                    _leftRightMargin = value;
                    this.OnPropertyChanged("LeftRightMargin");
                }
            }
        }
        #endregion


        internal abstract void SynchStrategyProperties(VirtualizationStrategy strategy);
        internal abstract VirtualizationStrategy CreateStrategy();

        #region PropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}
